#ifndef PHP_DL_H
#define PHP_DL_H

#include "php.h"
#include "php_ini.h"

/**
 * Excellent way to pass through a hashtable.
 *
 * zval* e
 * Hashtable hashtable
 *
 * **/
#define foreach( e, hashtable )											\
{																			\
	zval *e;																\
	MAKE_STD_ZVAL( e );														\
	for(zend_hash_internal_pointer_reset( hashtable );						\
		 zend_hash_get_current_data( hashtable , (void**) e ) != FAILURE;	\
		 zend_hash_move_forward( hashtable )								\
	) {

#define endforeach() }}

typedef void (*php_fn) (void**, void*);

//#define php_function_name(n) php_dl_##n

zend_bool load_dynamic_library( char* dlpath );
zend_bool unload_dynamic_library( char *dlpath );
void* load_native_function(DL_HANDLE handle, char* fname);
void call_native_function(void* fn, void** params, void* ret);
void copy_references(zval* from, void **to, int n);
void unload_all_loaded_libraries();

#endif
